package org.vestbjergbyggecenter.Controller;

import org.vestbjergbyggecenter.Model.Category;
import org.vestbjergbyggecenter.Model.CategoryRecords;

public class CategoryCtr {
	private CategoryRecords categories;
	private static CategoryCtr instance = null;
	
	public CategoryCtr()
	{
		categories=CategoryRecords.getInstance();
		
	}
	
	//customer control instance creation
    public static CategoryCtr getInstance()
    {
            if(instance==null)
            {
            	instance=new CategoryCtr();
            }
            return instance;
    }
    
    //create and add a category to the categories Array List
    public void createCategory(String newTitle, double newDiscount)
    {
    	Category category=new Category(newTitle, newDiscount);
    	categories.addCategory(category);
    }
    
    public void printCategory(String wantedTitle)
    {
    	categories.getCategoryByTitle(wantedTitle).print();
    }
    
    public void printCategories()
    {
    	categories.printCategories();
    }
    
    public void updateCategory(String wantedTitle, String newTitle, double newDiscount)
    {
    	categories.updateCategory(wantedTitle, newTitle, newDiscount);
    }
    
    public void deleteCategory(String wantedTitle)
    {
    	categories.deleteCategory(wantedTitle);
    }
}
